{% extends 'base.html' %}

{% block title %}添加碳盘查{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1>添加碳盘查</h1>
    <a href="{{ url_for('inventory.inventory_list') }}" class="btn btn-outline-secondary">返回列表</a>
</div>

<div class="card">
    <div class="card-body">
        <form method="post" action="{{ url_for('inventory.add_inventory') }}">
            <div class="row mb-3">
                <div class="col-md-6">
                    <label for="name" class="form-label">名称 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" id="name" name="name" required>
                </div>
                <div class="col-md-6">
                    <label for="status" class="form-label">状态 <span class="text-danger">*</span></label>
                    <select class="form-select" id="status" name="status" required>
                        <option value="新建">新建</option>
                        <option value="执行">执行</option>
                        <option value="完成">完成</option>
                    </select>
                </div>
            </div>

            <div class="row mb-3 d-none">
                <div class="col-md-6">
                    <input type="hidden" id="start_time" name="start_time" value="2025-07-02T01:41">
                </div>
                <div class="col-md-6">
                    <input type="hidden" id="end_time" name="end_time" value="2025-07-02T01:41">
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-md-6">
                    <label for="model_categories_id" class="form-label">模型分类 <span class="text-danger">*</span></label>
                    <select class="form-select" id="model_categories_id" name="model_categories_id" required>
                        <option value="">-- 选择模型分类 --</option>
                        {% for category in model_categories %}
                            <option value="{{ category.id }}">{{ '　' * (category.level - 1) }}|-- {{ category.name }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="col-md-6">
                    <label for="category_id" class="form-label">碳盘查目录 <span class="text-danger">*</span></label>
                    <select class="form-select" id="category_id" name="category_id" required>
                        <option value="">-- 选择盘查目录 --</option>
                        {% for category in inventory_categories %}
                            <option value="{{ category.id }}">{{ '　' * (category.level - 1) }}|-- {{ category.name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-md-6">
                    <label for="organization_boundary" class="form-label">组织边界 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" id="organization_boundary" name="organization_boundary" required>
                </div>
                <div class="col-md-6">
                    <label for="base_year" class="form-label">基准年 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" id="base_year" name="base_year" required>
                </div>
            </div>
            
            <div class="row mb-3">
                <div class="col-md-6">
                    <label for="belong_year" class="form-label">所属年份 <span class="text-danger">*</span></label>
                    <input type="number" class="form-control" id="belong_year" name="belong_year" min="2000" max="2100" value="2025" required>
                </div>
                <div class="col-md-6">
                    <label for="belong_month" class="form-label">所属月份 <span class="text-danger">*</span></label>
                    <select class="form-select" id="belong_month" name="belong_month" required>
                        {% for month in range(1,13) %}
                        <option value="{{ month }}" {% if month == 1 %}selected{% endif %}>{{ month }}月</option>
                        {% endfor %}
                    </select>
                </div>
            </div>

            <div class="row mb-3">
                <div class="col-md-6">
                    <label for="accounting_standard" class="form-label">核算标准 <span class="text-danger">*</span></label>
                    <input type="text" class="form-control" id="accounting_standard" name="accounting_standard" required>
                </div>
                <div class="col-md-6">
                    <label for="accounting_method" class="form-label">核算方式 <span class="text-danger">*</span></label>
                    <select class="form-select" id="accounting_method" name="accounting_method" required>
                        <option value="建模核算">建模核算</option>
                        <option value="数据上传">数据上传</option>
                    </select>
                </div>
            </div>

            <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                <button type="submit" class="btn btn-primary">保存</button>
                <a href="{{ url_for('inventory.inventory_list') }}" class="btn btn-outline-secondary">取消</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}